<div class="widget-box dataTables_wrapper">
	<?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'category-form',
			'action' => 'admin',
			'htmlOptions'=>array(
					'class'=>'jform',
			),
	)); ?>
		
		<?php 
		//$this->widget('zii.widgets.grid.CGridView', array(
		$this->widget('ext.selgridview.SelGridView', array(
			'id' => 'categories-grid',
			'dataProvider' => $model->search(),
			'template' => count($model->search()->getData())==0?'{items}':'{items}<div class="fg-toolbar widget-content"><a class="btn btn-primary" href="#" onclick="return actionDelete();">Delete</a>{pager}{summary}</div>',
			'selectableRows'=>count($model->search()->getData()),
			'itemsCssClass'=>'table table-bordered table-striped table-hover',
			'summaryCssClass'=>'summary widget-title',
			'cssFile'=> Yii::app()->request->baseUrl.WWWROOT_BACKEND."/css/gridview/styles.css",
			'htmlOptions'=>array('class'=>'widget-content nopadding grid-view'),
			//'filter' => $model,
			'columns' => array(
				array(
						'class' => 'CCheckBoxColumn',
						'htmlOptions' => array('class'=>'jform'),
						'headerHtmlOptions' => array('class' => 'jform jlb_checkbox_check_all jlb_checkbox_check_all_disable'),
						'header' => '<input type="checkbox" class="select-on-check-all"/>',
						'value' => '$data->primaryKey',
				),
				'name',
				array(
					'header'=>'Authors',
					'name' => 'username',
					'value' => '$data->getAuthorName($data->user_id)',
				),
				array(
					'header'=>'Country',
					'name' => 'countryname',
					'value' => '$data->getCountryName($data->country_id)',
				),
				array(
					'name' => 'is_published',
					'value' => '($data->is_published == 0) ? Yii::t(\'app\', \'No\') : Yii::t(\'app\', \'Yes\')',
					'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
				),
				'created',
				'modified',
				array(
					'class' => 'CButtonColumn',
				),
			),
		)); ?>
		
	<?php $this->endWidget(); ?>
</div>
<script type="text/javascript">
	function actionDelete()
	{
		if ($("input:checkbox[name='categories-grid_c0[]']:checked").length == 0) {
			alert('<?php echo 'Please select at least one item to remove.'; ?>');
			return false;
		}
		if (confirm('<?php echo 'Are you sure you want to delete?'; ?>')) $('#category-form').submit();
		return false;
	}
	</script>